package com.example.springpethospital.mapper;

import java.util.*;

import com.example.springpethospital.entity.IDAndName;
import org.apache.ibatis.annotations.*;

@Mapper
public interface IllcaseFileMapper {
    @Insert("insert into t_illcase_file(caseID, casetype, filetype, filepath) values (#{caseID}, #{casetype}, #{filetype}, #{filepath})")
    boolean AddFile(int caseID, int casetype, int filetype, String filepath);

    @Update("update t_illcase_file set filepath=#{filepath} where id=#{fileID}")
    boolean ModifyFile(int fileID, String filepath);

    @Update("update t_illcase_file set caseID=#{caseID}, casetype=#{casetype}, filetype=#{filetype} where id=#{fileID}")
    boolean ModifyFileProperties(int fileID, int caseID, int casetype, int filetype);

    @Delete("delete from t_illcase_file where id=#{fileID}")
    boolean RemoveFile(int fileID);

    @Select("select id from t_illcase_file where caseID=#{caseID} and casetype=#{casetype} and filetype=#{filetype}")
    List<Integer> getFileIDs(int caseID, int casetype, int filetype);

    @Select("select id, filepath as name from t_illcase_file where caseID=#{caseID} and casetype=#{casetype} and filetype=#{filetype}")
    List<IDAndName> getFileList(int caseID, int casetype, int filetype);

    @Select("select id from t_illcase_file where caseID=#{caseID}")
    List<Integer> getFileIDsByCaseID(int caseID);

    @Select("select filepath from t_illcase_file where id=#{fileID}")
    String getFilepath(int fileID);

    @Select("select filetype from t_illcase_file where id=#{fileID}")
    Integer getFiletype(int fileID);
}